package com.dayuanit.config;

import com.dayuanit.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.IOException;


@Configuration
public class WebAppConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //设置白名单
        String[] whiteUrl = new String[] {"/404", "/403", "/500","/applyUserRegister","/"};
        //注册自己的拦截器并设置拦截的请求路径,以及放行路径
        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/*").excludePathPatterns(whiteUrl);
        WebMvcConfigurer.super.addInterceptors(registry);

    }
}
